#ifndef H_TUXLIB_DATAGRAM_SOCKET_H
#define H_TUXLIB_DATAGRAM_SOCKET_H

#include "socket_common.hpp"
#include "socket.hpp"

namespace Tux { namespace Socket
{
    class InboundDatagramList; // Defined below

    template <typename DomainTraits>
    class DatagramSocket : public Socket<DomainTraits, DatagramSocketTraits>
    {
    public:
        size_t Receive(uint8_t* buffer, size_t capacity,
                       typename DomainTraits::SocketAddress* source = NULL);
        //size_t  ReceiveMany(InputDatagramList& list);
        void    Send(uint8_t* buffer, size_t length,
                     typename DomainTraits::SocketAddress const& destination);
    private:
        typedef Socket<DomainTraits, DatagramSocketTraits> BaseSocket;
    };
    
    class InboundDatagramList
    {
    public:
        class Entry
        {
        public:
            Entry();

            uint8_t* GetData() const    { return mData; }
            size_t GetLength() const    { return mLength; }
        private:
            uint8_t* mData;
            size_t mLength;
        };

        InboundDatagramList(unsigned list_capacity, unsigned max_datagram_size);
        ~InboundDatagramList();

        Entry const* GetNextEntry();
    private:
        Entry mEntry;
    };
}}

#include "inlines/datagram_socket.inl"

#endif

